package com.hjqjl.moduledemoa.ui;

import androidx.annotation.Nullable;

import android.content.Intent;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.hjqjl.moduledemoa.databinding.DemoaActivityMainBinding;
import com.hjqjl.whapplib.base.BaseActivity;
import com.hjqjl.whapplib.router.RouterPath;

// 在支持路由的页面上添加注解(必选)
// 这里的路径需要注意的是至少需要有两级，/xx/xx
@Route(path = RouterPath.DEMOA_MAIN)
public class MainActivity extends BaseActivity<DemoaActivityMainBinding> {
    private static final int REQUEST_CODE = 111;

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        LogUtils.v("onActivityResult REQUEST_CODE=" + requestCode + ",RESULT_CODE==>" + resultCode);
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
            ToastUtils.showShort("onActivityResult返回，REQUEST_CODE=" + REQUEST_CODE);
        }
    }

    @Override
    public void initData() {
        setTitle("标题DemoA");
        ToastUtils.showShort("this is moduleA");
    }

    @Override
    public void initListener() {
        pVBinding.demoaBtnMainTolauncher.setOnClickListener(v -> ARouter.getInstance().build(RouterPath.LAUNCHER_MAIN).navigation());
        pVBinding.demoaBtnMainTodemob.setOnClickListener(v -> ARouter.getInstance().build(RouterPath.DEMOB_MAIN).withString("key1", "我来自于DemoA").navigation());
        pVBinding.demoaBtnMainTodemobResult.setOnClickListener(v -> ARouter.getInstance().build(RouterPath.DEMOB_MAIN).withString("key1", "我来自于DemoA").navigation(MainActivity.this, REQUEST_CODE));
    }
}